package com.version1_4.controller;

import com.alibaba.fastjson.JSONObject;
import com.version1_3.controller.SubscriController1_3;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;

/**
 * Created by reeveslee on 16/4/27.
 */
@Controller
public class SubscriController1_4 {
    private static final Logger LOGGER = Logger.getLogger(SubscriController1_4.class);

    @Autowired
    private SubscriController1_3 subscriController13;

    /**
     * 在订阅界面更新用户关注分类内容或者给订阅的三级分类排序  - 目前iOS订阅功能只用了这一个接口
     */
    @RequestMapping(value = "/version1_4/subscri/changeUserFocus/{userId}", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String changeUserFocus(@RequestBody JSONObject jsonObject, @PathVariable("userId") int userId) {
        return subscriController13.changeUserFocus(jsonObject, userId);
    }

    /**
     * 订阅单独的三级分类
     */
    @RequestMapping(value = "/version1_4/subscri/subscriThirdType/{userId}/{firstType}/{thirdTypeId}", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String subscriThirdType(@PathVariable("userId") int userId, @PathVariable("thirdTypeId") int thirdTypeId, @PathVariable("firstType") int firstType) {
        return subscriController13.subscriThirdType(userId, thirdTypeId, firstType);
    }


    /**
     * 取消订阅单独的三级分类
     */
    @RequestMapping(value = "/version1_4/subscri/removeSubscri/{userId}/{firstType}/{thirdTypeId}", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String removeSubscri(@PathVariable("userId") int userId, @PathVariable("firstType") int firstType, @PathVariable("thirdTypeId") int thirdTypeId) {
        return subscriController13.removeSubscri(userId, firstType, thirdTypeId);
    }

    /**
     * 获取热门分类
     */
    @RequestMapping(value = "/version1_4/subscri/getHotSortation/{number}", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String getHotSortation(@PathVariable("number") int number) throws UnsupportedEncodingException {
        return subscriController13.getHotSortation(number);
    }
}
